package swg.utils;



import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class RunningTime
{
	protected long tsStart;
	protected long tsEnd;
	
	public RunningTime()
	{
		tsStart = System.currentTimeMillis();
	}

	public void start()
	{
		tsStart = System.currentTimeMillis();
		tsEnd = 0;
	}
	
	public void stop()
	{
		tsEnd = System.currentTimeMillis();
	}
	
	
	public long getElapsedMillisecs()
	{
		long elapsed = tsEnd - tsStart;
		return elapsed;
	}
	
	
	public String getElapsedDescr()
	{
		SimpleDateFormat fmtElps = new SimpleDateFormat("HH:mm:ss");
		fmtElps.setTimeZone(TimeZone.getTimeZone("GMT"));
		long elapsed = tsEnd - tsStart;
		String res = fmtElps.format(new Date(elapsed));
		return res;
	}
	
	public String toString()
	{
		return getElapsedDescr();
	}
	
}
